home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / l33t_liek_jeff_k / leet source / HQInfoPanelController.m < prev    next >
Text File  |  2000-06-23  |  2KB  |  50 lines

  1. // HQInfoPanelController.m
  2. //
  3. // You may freely copy, distribute, and reuse the code in this example.
  4. // Apple disclaims any warranty of any kind, expressed or  implied, as to its
  5. // fitness for any particular use.
  6.  
  7. #import "HQInfoPanelController.h"
  8.  
  9. #define README_FILE @"README"
  10. #define README_EXTENSION @"rtf"
  11.  
  12. @implementation HQInfoPanelController
  13.  
  14. + (id)sharedInfoPanelController {
  15.     static HQInfoPanelController *sharedInstance = nil;
  16.     if (!sharedInstance) {
  17.         sharedInstance = [[HQInfoPanelController alloc] init];
  18.     }
  19.     return sharedInstance;
  20. }
  21.  
  22. - (id)init {
  23.     return [super initWithWindowNibName:@"HQInfo" owner:self];
  24. }
  25.  
  26. - (void)windowDidLoad {
  27.     extern const double HQHackMacVersionNumber;
  28.     NSString *readMePath;
  29.  
  30.     [super windowDidLoad];
  31.  
  32.     // It is assumed that versionField comes out of the nib with a format string with one %f which is to be replaced by the version number.
  33.     [versionField setStringValue:[NSString stringWithFormat:[versionField stringValue], HQHackMacVersionNumber]];
  34.  
  35.     // Load up the ReadMe
  36.     readMePath = [[NSBundle bundleForClass:[self class]] pathForResource:README_FILE ofType:README_EXTENSION];
  37.     if (readMePath) {
  38.         [textView replaceCharactersInRange:NSMakeRange(0, [[textView string] length]) withRTF:[NSData dataWithContentsOfFile:readMePath]];
  39.         [textView scrollRangeToVisible:NSMakeRange(0, 0)];
  40.     }
  41. }
  42.  
  43. - (void)showWindow:(id)sender {
  44.     NSWindow *window = [self window];
  45.     [window center];
  46.     [super showWindow:sender];
  47. }
  48.  
  49. @end
  50.